package com.idconfirmsystem.activity;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.dom4j.DocumentException;
import org.kymjs.kjframe.http.HttpCallBack;

import u.aly.br;
import u.aly.q;

import com.idconfirmsystem.Conf;
import com.idconfirmsystem.Constants;
import com.idconfirmsystem.R;
import com.idconfirmsystem.handler.TaskDetailHandler;
import com.idconfirmsystem.model.BranchTask;
import com.idconfirmsystem.model.BranchTaskList;
import com.idconfirmsystem.model.BranchTaskQuery;
import com.idconfirmsystem.model.QueryRet;
import com.idconfirmsystem.model.Task;
import com.idconfirmsystem.model.UserBean;
import com.idconfirmsystem.parse.BranchParse;
import com.idconfirmsystem.remote.ConfirmApi;
import com.idconfirmsystem.remote.TaskApi;
import com.idconfirmsystem.util.DateUtil;
import com.idconfirmsystem.util.FileUtils;
import com.idconfirmsystem.util.XmlUtils;

import android.os.Bundle;
import android.os.Handler;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.Button;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.Toast;

public class TaskDetailDialog extends Activity {

	// handler
	// private Handler handler = new TaskDetailHandler(this);

	// 布局元素
	private Element el = new Element();

	private class Element {
		private TextView taskNum;
		private TextView startTime;
		private TextView pilotman;
		private TextView driver;
		private TextView carNum;
		private TextView protectOne;
		private TextView protectTwo;
		private Button addButton;
		TextView[] detaiTextViews = { taskNum, startTime, pilotman, driver,
				carNum, protectOne, protectTwo };

		private TableLayout taskTableLayout;
	};

	private Context context = TaskDetailDialog.this;
	// 运行时临时变量
	private RuntimeObject ru = new RuntimeObject();

	private class RuntimeObject {
		String[] detailString = { "任务编号：",
				"出发日期：" + DateUtil.getCurrentDateByFormat("yyyyMMdd"), "业务员：",
				"驾驶员：", "车辆牌号：", "护卫1\t：", "护卫2\t：" };

		BranchParse branchParse;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_task_detail);

		// Bundle bundle = getIntent().getExtras();
		initView();
		// querySubTaskList(bundle.getString("taskid"));

	}

	private void initView() {
		el.taskNum = (TextView) findViewById(R.id.task_num);
		el.startTime = (TextView) findViewById(R.id.task_start_time);
		el.pilotman = (TextView) findViewById(R.id.task_salesman);
		el.driver = (TextView) findViewById(R.id.task_driver);
		el.carNum = (TextView) findViewById(R.id.task_car_num);
		el.protectOne = (TextView) findViewById(R.id.task_protect1);
		el.protectTwo = (TextView) findViewById(R.id.task_protect2);

		el.taskTableLayout = (TableLayout) findViewById(R.id.task_tablelayout);
		initViewData();
	}

	private void initViewData() {
		el.taskNum.setText(ru.detailString[0]
				+ Conf.TaskProcess.curTask.getId());
		el.startTime.setText(ru.detailString[1]);
		el.pilotman.setText(ru.detailString[2]
				+ Conf.TaskProcess.curTask.getPilot_name());
		el.driver.setText(ru.detailString[3]
				+ Conf.TaskProcess.curTask.getClerk_name());
		el.carNum.setText(ru.detailString[4]
				+ Conf.TaskProcess.curTask.getCar_name());
		el.protectOne.setText(ru.detailString[5]
				+ Conf.TaskProcess.curTask.getEscort_name1());
		el.protectTwo.setText(ru.detailString[6]
				+ Conf.TaskProcess.curTask.getEscort_name2());

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.task, menu);
		return true;
	}

}
